<template>
    <view class="x-center x-normal-top">加载中...</view>
</template>

<script setup name="start">
import {Http, Msg, Helper, Constant, Cache} from 'core';
import userStore from '@/stores/framework/user';
const UserStore = userStore();

onLoad(async (option) => {

  start();
})

const start = async () => {
  // #ifdef MP-ALIPAY
  my.getAuthCode({
    success: async (res) => {
      if(Helper.empty(res.authCode)) {
        Msg.error("获取授权失败");
        return;
      }

      let flag = await UserStore.login(res.authCode)
      if(flag) {
        let query = Cache.get(Constant.LAUNCH_QUERY);
        if(query.type == 'order_confirm') {
          uni.redirectTo({
            url: "/pages/order/create?orderNo=" + query.orderNo
          })
        } else {
          uni.navigateTo({url: "/pages/index"})
        }
      }
    },
    fail: (err) => {
      Msg.error(err.errorMessage);
    }
  })
  // #endif
}

</script>

<style scoped lang="less">

</style>
